PROJECT = prj4

CLIENT = quadrc
DAEMON = quadrd

TARGET = $(CLIENT) $(DAEMON)

#Human generated files (should be submitted).
SRC_FILES = \
  quadrc.c \
  quadrd.c \
  quadrdefs.h \
  fns.c \
  fns.h \
  Makefile \
  README

#Object files.
CLIENT_OBJS = \
  $(CLIENT).o 

DAEMON_OBJS = \
  $(DAEMON).o fns.o

CC = gcc
CFLAGS = -g -Wall --std=c99
LDFLAGS = -ldl -lm

#This target builds the main executable for the project.
all:		$(TARGET)

$(CLIENT):  	$(CLIENT_OBJS)
		$(CC) $(CLIENT_OBJS) $(LDFLAGS) -o $@

$(DAEMON):  	$(DAEMON_OBJS)
		$(CC) $(DAEMON_OBJS) $(LDFLAGS) -o $@

#Removes all objects and executables.
clean:
		rm -f $(CLIENT_OBJS) $(DAEMON_OBJS) $(TARGET) *~ *.bak *.o 

#This target makes a archive containing all the project source files,
#suitable for submission.
submit:		$(SRC_FILES)
		tar -cvf $(PROJECT).tar $(SRC_FILES)
		gzip $(PROJECT).tar

#This target outputs dependencies of all C files on stdout.  The output can
#then be cut-and-pasted into this Makefile.
DEPEND:
		$(CC) -MM *.c

#Automatically produced dependencies pasted in from output of 'make DEPEND'.
quadrc.o:	quadrc.c quadrdefs.h fns.h
quadrd.o:	quadrd.c quadrdefs.h fns.h
fns.o:		fns.c fns.h
